# Contributor: Sergei Lukin <sergej.lukin@gmail.com>
# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=chicken
pkgver=5.3.0
pkgrel=1
pkgdesc="R5RS and R7RS compatible scheme compiler and interpreter"
url="https://call-cc.org/"
arch="all"
license="BSD-3-Clause"
depends="gcc libc-dev $pkgname-dev $pkgname-libs"
subpackages="$pkgname-doc $pkgname-libs $pkgname-dev $pkgname-feathers::noarch"
source="https://code.call-cc.org/releases/$pkgver/chicken-$pkgver.tar.gz
	redundant-rpath.patch"

# secfixes:
#   4.12.0-r3:
#     - CVE-2017-6949
#   4.12.0-r2:
#     - CVE-2017-9334
#   4.11.1-r0:
#     - CVE-2016-6830
#     - CVE-2016-6831

build() {
	# chicken does not support parallel builds.
	make -j1 PREFIX=/usr
}

check() {
	make -j1 check
}

package() {
	# chicken does not support parallel installs.
	make -j1 PREFIX=/usr DESTDIR="$pkgdir" install

	# Move documentation to /usr/share/doc.
	mkdir -p "$pkgdir"/usr/share/doc/
	mv "$pkgdir"/usr/share/$pkgname/doc \
		"$pkgdir"/usr/share/doc/$pkgname

	# Move license to /usr/share/licenses
	mkdir -p "$pkgdir"/usr/share/licenses/$pkgname
	mv "$pkgdir"/usr/share/doc/$pkgname/LICENSE \
		"$pkgdir"/usr/share/licenses/$pkgname/
}

feathers() {
	pkgdesc="A debugger for compiled chicken programs"
	depends="tk"

	mkdir -p "$subpkgdir"/usr/bin/ \
		"$subpkgdir"/usr/share/chicken/
	mv "$pkgdir"/usr/bin/feathers \
		"$subpkgdir"/usr/bin/
	mv "$pkgdir"/usr/share/chicken/feathers.tcl \
		"$subpkgdir"/usr/share/chicken/
}

sha512sums="
8fcc08a1ba44cde42c95820695a11858a3b7ff39a4b577bc5afb894c53513661aab2dc5b8e608e1d9d26648e314551052041626c4c8e519fcb9f8af324386e02  chicken-5.3.0.tar.gz
003b0930c6837f4be0e61cd2ebe76d4bd8f594b81f9325efaaa7020d97a6682ef09e58768b0805fdd696a2cc144615b94b3d0652217ef61f276b50aef41892e6  redundant-rpath.patch
"
